package main;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.NumberFormat;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
import javax.swing.UIManager;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.DefaultTableModel;

import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.AbstractAction;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.Action;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;


public class main_window {


	private JFrame frmWineGameWine;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					main_window window = new main_window();
					window.frmWineGameWine.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public main_window() {
		try {
			  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
			} catch(Exception e) {
			  System.out.println("Error setting native LAF: " + e);
			}
		values.setIDGame(0);
		values.setNGame("Join a game");


		
		timer = new Timer();
		initialize();

	    timer.scheduleAtFixedRate(new RemindTask(), 0, //initial delay
	        15 * 1000); //subsequent rate
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		ImageIcon img = null;
		try {
			img = new ImageIcon(new URL(connect.Dev_URL() + "icon.png"));
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		frmWineGameWine = new JFrame();
		frmWineGameWine.setIconImage(img.getImage());
		 try {
			wait = new ImageIcon(new URL(connect.Dev_URL() + "att.gif"));
			go = new ImageIcon(new URL(connect.Dev_URL() + "ok.gif"));
		} catch (MalformedURLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		frmWineGameWine.setTitle("Wine Game-Wine Supply Chain Council");
		frmWineGameWine.setBounds(100, 100, 842, 707);
		frmWineGameWine.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		SpringLayout springLayout = new SpringLayout();
		frmWineGameWine.getContentPane().setLayout(springLayout);
		SplashScreen nn;
		try {
			nn = new SplashScreen(new URL(connect.Dev_URL() + "splash2.png"), frmWineGameWine, 2000);
			nn.setVisible(true);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		JMenuBar menuBar = new JMenuBar();
		springLayout.putConstraint(SpringLayout.NORTH, menuBar, 0, SpringLayout.NORTH, frmWineGameWine.getContentPane());
		springLayout.putConstraint(SpringLayout.WEST, menuBar, 0, SpringLayout.WEST, frmWineGameWine.getContentPane());
		springLayout.putConstraint(SpringLayout.SOUTH, menuBar, 21, SpringLayout.NORTH, frmWineGameWine.getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, menuBar, 0, SpringLayout.EAST, frmWineGameWine.getContentPane());
		frmWineGameWine.getContentPane().add(menuBar);
		
		JMenu mnFile = new JMenu("File");
		menuBar.add(mnFile);
		
		tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		springLayout.putConstraint(SpringLayout.WEST, tabbedPane, 0, SpringLayout.WEST, frmWineGameWine.getContentPane());
		springLayout.putConstraint(SpringLayout.SOUTH, tabbedPane, -38, SpringLayout.SOUTH, frmWineGameWine.getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, tabbedPane, 0, SpringLayout.EAST, menuBar);
		frmWineGameWine.getContentPane().add(tabbedPane);
		JPanel panel_ini = new JPanel();
		tabbedPane.addTab("Start", null, panel_ini, null);
		panel_ini.setLayout(null);
		
		JLabel lblNewLabel_7 = new JLabel("Welcome to The Wine Game");
		lblNewLabel_7.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblNewLabel_7.setBounds(10, 11, 715, 43);
		panel_ini.add(lblNewLabel_7);
		
		JLabel lblNewLabel_8 = new JLabel("Please join a game to start.");
		lblNewLabel_8.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblNewLabel_8.setBounds(43, 68, 173, 23);
		panel_ini.add(lblNewLabel_8);
		
		button_4 = new JButton("Finish Planning Week");
		button_4.setBounds(226, 70, 81, 23);
		panel_ini.add(button_4);
		springLayout.putConstraint(SpringLayout.SOUTH, button_4, -6, SpringLayout.NORTH, tabbedPane);
		button_4.setAction(action);

		JPanel panel = new JPanel();
		tabbedPane.addTab("Order Management", null, panel, null);
		SpringLayout sl_panel = new SpringLayout();
		panel.setLayout(sl_panel);
		
		JLabel lblOrderManagement = new JLabel("Order Management");
		lblOrderManagement.setFont(new Font("Tahoma", Font.PLAIN, 14));
		sl_panel.putConstraint(SpringLayout.NORTH, lblOrderManagement, 10, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.WEST, lblOrderManagement, 26, SpringLayout.WEST, panel);
		panel.add(lblOrderManagement);
		
		JPanel panel_6 = new JPanel();
		sl_panel.putConstraint(SpringLayout.NORTH, panel_6, 6, SpringLayout.SOUTH, lblOrderManagement);
		sl_panel.putConstraint(SpringLayout.WEST, panel_6, 10, SpringLayout.WEST, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, panel_6, 181, SpringLayout.SOUTH, lblOrderManagement);
		sl_panel.putConstraint(SpringLayout.EAST, panel_6, -10, SpringLayout.EAST, panel);
		panel_6.setBorder(new TitledBorder(null, "Customer Order Information", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel.add(panel_6);
		panel_6.setLayout(null);
		
		textField = new JTextField();
		textField.setHorizontalAlignment(SwingConstants.CENTER);
		textField.setEditable(false);
		textField.setBounds(134, 82, 62, 20);
		panel_6.add(textField);
		textField.setColumns(10);
		
		JLabel lblCurrentImporterOrder = new JLabel("Importer Order White");
		lblCurrentImporterOrder.setLabelFor(textField);
		lblCurrentImporterOrder.setBounds(10, 85, 121, 14);
		panel_6.add(lblCurrentImporterOrder);
		
		JLabel lblContainers = new JLabel("Pallets");
		lblContainers.setBounds(206, 85, 81, 14);
		panel_6.add(lblContainers);
		
		JLabel lblCurrentImporterBacklog = new JLabel("Importer Backlog White");
		lblCurrentImporterBacklog.setBounds(10, 110, 132, 14);
		panel_6.add(lblCurrentImporterBacklog);
		
		textField_1 = new JTextField();
		textField_1.setHorizontalAlignment(SwingConstants.CENTER);
		textField_1.setEditable(false);
		textField_1.setBounds(134, 107, 62, 20);
		panel_6.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel lblContainers_1 = new JLabel("Pallets");
		lblContainers_1.setBounds(206, 110, 92, 14);
		panel_6.add(lblContainers_1);
		
		JPanel panel_7 = new JPanel();
		panel_7.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Order History", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_7.setBounds(266, 13, 525, 145);
		panel_6.add(panel_7);
		panel_7.setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(6, 16, 509, 122);
		panel_7.add(scrollPane);
		
		table = new JTable();
		table.setFont(new Font("Tahoma", Font.PLAIN, 9));
		scrollPane.setViewportView(table);
		table.setSurrendersFocusOnKeystroke(true);
		table.setBackground(new Color(255, 255, 255));
		table.setRowSelectionAllowed(false);
		table.setToolTipText("");
		table.setBorder(null);
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Week", "Red Order", "Red Backlog", "Red Ship", "White Order", "White Backlog", "White Ship"
			}
		));


		JButton btnMakeShipment = new JButton("Make Shipment");
		btnMakeShipment.setAction(action_16);
		btnMakeShipment.setBounds(78, 135, 132, 23);
		panel_6.add(btnMakeShipment);
		
		JPanel panel_8 = new JPanel();
		sl_panel.putConstraint(SpringLayout.NORTH, panel_8, 6, SpringLayout.SOUTH, panel_6);
		sl_panel.putConstraint(SpringLayout.WEST, panel_8, 0, SpringLayout.WEST, panel_6);
		sl_panel.putConstraint(SpringLayout.SOUTH, panel_8, 165, SpringLayout.SOUTH, panel_6);
		sl_panel.putConstraint(SpringLayout.EAST, panel_8, 0, SpringLayout.EAST, panel_6);
		panel_8.setBorder(new TitledBorder(null, "Production Order Management", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel.add(panel_8);
		panel_8.setLayout(null);
		
		JPanel panel_9 = new JPanel();
		panel_9.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Production Order History", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_9.setBounds(347, 14, 444, 134);
		panel_8.add(panel_9);
		panel_9.setLayout(null);
		
		JScrollPane scrollPane_1 = new JScrollPane();
		scrollPane_1.setBounds(10, 21, 424, 102);
		panel_9.add(scrollPane_1);
		
		table_1 = new JTable();
		table_1.setFont(new Font("Tahoma", Font.PLAIN, 9));
		scrollPane_1.setViewportView(table_1);
		table_1.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Week Order Gen.", "Red (Pallets)", "White (Pallets)", "Week Order Avail."
			}
		));
		
		JLabel lblCurrentWeekProduction = new JLabel("Week Avail. Production White Wines");
		lblCurrentWeekProduction.setBounds(10, 34, 196, 14);
		panel_8.add(lblCurrentWeekProduction);
		
		JLabel lblCurrentWeekProduction_1 = new JLabel(" Week Avail. Production Red Wines");
		lblCurrentWeekProduction_1.setBounds(10, 63, 186, 14);
		panel_8.add(lblCurrentWeekProduction_1);
		
		textField_2 = new JTextField();
		textField_2.setHorizontalAlignment(SwingConstants.CENTER);
		textField_2.setEditable(false);
		textField_2.setBounds(200, 31, 62, 20);
		panel_8.add(textField_2);
		textField_2.setColumns(10);
		
		textField_3 = new JTextField();
		textField_3.setHorizontalAlignment(SwingConstants.CENTER);
		textField_3.setEditable(false);
		textField_3.setBounds(200, 60, 62, 20);
		panel_8.add(textField_3);
		textField_3.setColumns(10);
		
		JLabel lblPallets = new JLabel("Pallets");
		lblPallets.setBounds(272, 34, 92, 14);
		panel_8.add(lblPallets);
		
		JLabel lblPallets_1 = new JLabel("Pallets");
		lblPallets_1.setBounds(272, 63, 92, 14);
		panel_8.add(lblPallets_1);
		
		JButton btnMakeProductionOrder = new JButton("Make Bottling Order");
		btnMakeProductionOrder.setAction(action_17);
		btnMakeProductionOrder.setBounds(103, 112, 145, 23);
		panel_8.add(btnMakeProductionOrder);
		
		JPanel panel_10 = new JPanel();
		panel_10.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Shipping/Inventory Information", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		sl_panel.putConstraint(SpringLayout.NORTH, panel_10, 6, SpringLayout.SOUTH, panel_8);
		sl_panel.putConstraint(SpringLayout.WEST, panel_10, 10, SpringLayout.WEST, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, panel_10, 167, SpringLayout.SOUTH, panel_8);
		sl_panel.putConstraint(SpringLayout.EAST, panel_10, 0, SpringLayout.EAST, panel_6);
		
		JLabel lblImporterBacklogRed = new JLabel("Importer Backlog Red");
		lblImporterBacklogRed.setBounds(10, 57, 121, 14);
		panel_6.add(lblImporterBacklogRed);
		
		JLabel lblNewJgoodiesLabel = new JLabel("Importer Order Red");
		lblNewJgoodiesLabel.setBounds(10, 32, 121, 14);
		panel_6.add(lblNewJgoodiesLabel);
		
		textField_5 = new JTextField();
		textField_5.setHorizontalAlignment(SwingConstants.CENTER);
		textField_5.setEditable(false);
		textField_5.setBounds(134, 54, 62, 20);
		panel_6.add(textField_5);
		textField_5.setColumns(10);
		
		textField_6 = new JTextField();
		textField_6.setHorizontalAlignment(SwingConstants.CENTER);
		textField_6.setEditable(false);
		textField_6.setBounds(134, 29, 62, 20);
		panel_6.add(textField_6);
		textField_6.setColumns(10);
		
		JLabel lblPallets_2 = new JLabel("Pallets");
		lblPallets_2.setBounds(206, 32, 92, 14);
		panel_6.add(lblPallets_2);
		
		JLabel lblPallets_3 = new JLabel("Pallets");
		lblPallets_3.setBounds(206, 57, 92, 14);
		panel_6.add(lblPallets_3);
		panel.add(panel_10);
		panel_10.setLayout(null);
		
		JPanel panel_11 = new JPanel();
		panel_11.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Inventory/Backlog History", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_11.setBounds(365, 28, 426, 122);
		panel_10.add(panel_11);
		panel_11.setLayout(null);
		
		JScrollPane scrollPane_2 = new JScrollPane();
		scrollPane_2.setBounds(6, 16, 414, 99);
		panel_11.add(scrollPane_2);
		
		table_2 = new JTable();
		table_2.setFont(new Font("Tahoma", Font.PLAIN, 9));
		scrollPane_2.setViewportView(table_2);
		table_2.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
					"Week", "Red Inv.", "Red Backlog", "White Inv.", "White Backlog"
			}
		));
		
		JPanel panel_16 = new JPanel();
		panel_16.setLayout(null);
		panel_16.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Shipping History", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_16.setBounds(10, 28, 426, 122);
		panel_10.add(panel_16);
		
		JScrollPane scrollPane_5 = new JScrollPane();
		scrollPane_5.setBounds(6, 16, 337, 99);
		panel_16.add(scrollPane_5);
		
		table_5 = new JTable();
		table_5.setFont(new Font("Tahoma", Font.PLAIN, 9));
		table_5.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Week", "Units", "Red Ship", "White Ship", "Week Arrive"
			}
		));
		scrollPane_5.setViewportView(table_5);

		
		panel_1 = new JPanel();
		tabbedPane.addTab("Bottling", wait, panel_1, null);
		SpringLayout sl_panel_1 = new SpringLayout();
		panel_1.setLayout(sl_panel_1);
		
		JLabel lblBotllingManagementPanel = new JLabel("Botlling Management Panel");
		sl_panel_1.putConstraint(SpringLayout.NORTH, lblBotllingManagementPanel, 10, SpringLayout.NORTH, panel_1);
		sl_panel_1.putConstraint(SpringLayout.WEST, lblBotllingManagementPanel, 10, SpringLayout.WEST, panel_1);
		lblBotllingManagementPanel.setFont(new Font("Tahoma", Font.PLAIN, 16));
		panel_1.add(lblBotllingManagementPanel);
		
		JPanel panel_12 = new JPanel();
		sl_panel_1.putConstraint(SpringLayout.NORTH, panel_12, 10, SpringLayout.SOUTH, lblBotllingManagementPanel);
		sl_panel_1.putConstraint(SpringLayout.WEST, panel_12, 30, SpringLayout.WEST, panel_1);
		sl_panel_1.putConstraint(SpringLayout.EAST, panel_12, -34, SpringLayout.EAST, panel_1);
		panel_12.setBorder(new TitledBorder(null, "Line 1", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_1.add(panel_12);
		
		JPanel panel_13 = new JPanel();
		sl_panel_1.putConstraint(SpringLayout.NORTH, panel_13, 282, SpringLayout.NORTH, panel_1);
		sl_panel_1.putConstraint(SpringLayout.WEST, panel_13, 30, SpringLayout.WEST, panel_1);
		sl_panel_1.putConstraint(SpringLayout.SOUTH, panel_13, -24, SpringLayout.SOUTH, panel_1);
		sl_panel_1.putConstraint(SpringLayout.EAST, panel_13, -34, SpringLayout.EAST, panel_1);
		sl_panel_1.putConstraint(SpringLayout.SOUTH, panel_12, -6, SpringLayout.NORTH, panel_13);
		panel_12.setLayout(null);
		
		JPanel panel_15 = new JPanel();
		panel_15.setBorder(new TitledBorder(null, "Next Week Line Schedule", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_15.setBounds(348, 11, 399, 211);
		panel_12.add(panel_15);
		panel_15.setLayout(new GridLayout(0, 1, 0, 0));
		
		JScrollPane scrollPane_4 = new JScrollPane();
		panel_15.add(scrollPane_4);
		
		table_4 = new JTable();
		scrollPane_4.setColumnHeaderView(table_4);
		panel_13.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Line 2", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_1.add(panel_13);
		panel_13.setLayout(null);
		table_4.setModel(new DefaultTableModel(
				new Object[][] {
				},
				new String[] {
					"ID", "Wine Type", "Qaunt. Pallets", "Prod.Time", "Setup Time"
				}
			));
		table_4.getColumnModel().getColumn(0).setMaxWidth(0);
		table_4.getColumnModel().getColumn(0).setMinWidth(0);
		table_4.getColumnModel().getColumn(0).setWidth(0);
			scrollPane_4.setViewportView(table_4);
			
			 btnNewButton_1 = new JButton("Move Order Up");
			btnNewButton_1.setAction(action_6);
			btnNewButton_1.setBounds(215, 131, 123, 23);
			panel_12.add(btnNewButton_1);
			
			 btnMoveOrderDwn = new JButton("Move Order Down");
			btnMoveOrderDwn.setAction(action_7);
			btnMoveOrderDwn.setBounds(215, 165, 123, 23);
			panel_12.add(btnMoveOrderDwn);
			
			JLabel lblTotallProductionRed = new JLabel("Total Production Red");
			lblTotallProductionRed.setBounds(10, 31, 137, 14);
			panel_12.add(lblTotallProductionRed);
			
			JLabel lblTotalProductionWhite = new JLabel("Total Production White");
			lblTotalProductionWhite.setBounds(10, 56, 137, 14);
			panel_12.add(lblTotalProductionWhite);
			
			JLabel lblTotalProduction = new JLabel("Total Production Time");
			lblTotalProduction.setBounds(10, 81, 137, 14);
			panel_12.add(lblTotalProduction);
			
			JLabel lblLineEfficiency = new JLabel("Line Efficiency");
			lblLineEfficiency.setBounds(10, 106, 137, 14);
			panel_12.add(lblLineEfficiency);
			
			 btnNewProdOrder = new JButton("New Prod. Order");
			btnNewProdOrder.setAction(action_3);
			btnNewProdOrder.setBounds(63, 131, 123, 23);
			panel_12.add(btnNewProdOrder);
			
			 btnNewButton = new JButton("New button");
			 btnNewButton.addActionListener(new ActionListener() {
			 	public void actionPerformed(ActionEvent arg0) {
			 	}
			 });
			btnNewButton.setAction(action_14);
			btnNewButton.setBounds(130, 199, 152, 23);
			panel_12.add(btnNewButton);
			
			 btnDeleteProdOrder = new JButton("Delete Prod. Order");
			btnDeleteProdOrder.setAction(action_5);
			btnDeleteProdOrder.setBounds(63, 165, 123, 23);
			panel_12.add(btnDeleteProdOrder);
			
			lblNewLabel = new JLabel("xx");
			lblNewLabel.setBounds(157, 31, 46, 14);
			panel_12.add(lblNewLabel);
			
			label_1 = new JLabel("xx");
			label_1.setBounds(157, 56, 46, 14);
			panel_12.add(label_1);
			
			label_3 = new JLabel("xx");
			label_3.setBounds(157, 81, 46, 14);
			panel_12.add(label_3);
			
			label_6 = new JLabel("xx");
			label_6.setBounds(157, 106, 46, 14);
			panel_12.add(label_6);
			
			JLabel lblPreviousWine = new JLabel("Previous Wine :");
			lblPreviousWine.setBounds(201, 31, 81, 14);
			panel_12.add(lblPreviousWine);
			
			lblNewLabel_1 = new JLabel("xx");
			lblNewLabel_1.setBounds(280, 31, 46, 14);
			panel_12.add(lblNewLabel_1);
			
			JLabel lblMaxLineCapa = new JLabel("Max Line Capa.:");
			lblMaxLineCapa.setBounds(201, 81, 81, 14);
			panel_12.add(lblMaxLineCapa);
			
			JLabel label_24 = new JLabel("10");
			label_24.setBounds(280, 81, 46, 14);
			panel_12.add(label_24);
		JPanel panel_14 = new JPanel();
		panel_14.setBorder(new TitledBorder(null, "Next Week Line Schedule", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_14.setBounds(348, 22, 399, 211);
		panel_13.add(panel_14);
		panel_14.setLayout(new GridLayout(0, 1, 0, 0));
		
		JScrollPane scrollPane_3 = new JScrollPane();
		panel_14.add(scrollPane_3);
		
		table_3 = new JTable();
		table_3.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"ID", "Wine Type", "Qaunt. Pallets", "Prod.Time", "Setup Time"
			}
		));
		table_3.getColumnModel().getColumn(0).setMaxWidth(0);
		table_3.getColumnModel().getColumn(0).setMinWidth(0);
		table_3.getColumnModel().getColumn(0).setWidth(0);
		scrollPane_3.setViewportView(table_3);
		
		JLabel lblTotalProductionRed = new JLabel("Total Production Red");
		lblTotalProductionRed.setBounds(10, 46, 137, 14);
		panel_13.add(lblTotalProductionRed);
		
		JLabel lblTotalProductionWhite_1 = new JLabel("Total Production White");
		lblTotalProductionWhite_1.setBounds(10, 71, 137, 14);
		panel_13.add(lblTotalProductionWhite_1);
		
		JLabel lblTotalProductionTime = new JLabel("Total Production Time");
		lblTotalProductionTime.setBounds(10, 96, 137, 14);
		panel_13.add(lblTotalProductionTime);
		
		JLabel label_5 = new JLabel("Line Efficiency");
		label_5.setBounds(10, 121, 137, 14);
		panel_13.add(label_5);
		
		 button = new JButton("New Prod. Order");
		button.setAction(action_4);
		button.setBounds(59, 146, 123, 23);
		panel_13.add(button);
		
		 button_1 = new JButton("Delete Prod. Order");
		button_1.setAction(action_8);
		button_1.setBounds(59, 180, 123, 23);
		panel_13.add(button_1);
		
		 button_2 = new JButton("Move Order Up");
		button_2.setAction(action_9);
		button_2.setBounds(216, 146, 123, 23);
		panel_13.add(button_2);
		
		 button_3 = new JButton("Move Order Down");
		button_3.setAction(action_10);
		button_3.setBounds(216, 180, 123, 23);
		panel_13.add(button_3);
		
		label_7 = new JLabel("xx");
		label_7.setBounds(157, 121, 46, 14);
		panel_13.add(label_7);
		
		label_8 = new JLabel("xx");
		label_8.setBounds(157, 96, 46, 14);
		panel_13.add(label_8);
		
		label_9 = new JLabel("xx");
		label_9.setBounds(157, 71, 46, 14);
		panel_13.add(label_9);
		
		label_10 = new JLabel("xx");
		label_10.setBounds(157, 46, 46, 14);
		panel_13.add(label_10);
		
		btnNewButton_2 = new JButton("New button");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnNewButton_2.setAction(action_15);
		btnNewButton_2.setBounds(131, 210, 155, 23);
		panel_13.add(btnNewButton_2);
		
		JLabel label_11 = new JLabel("Previous Wine :");
		label_11.setBounds(216, 46, 81, 14);
		panel_13.add(label_11);
		
		 label_12 = new JLabel("xx");
		label_12.setBounds(295, 46, 46, 14);
		panel_13.add(label_12);
		
		JLabel label_23 = new JLabel("Max Line Capa.:");
		label_23.setBounds(216, 96, 81, 14);
		panel_13.add(label_23);
		
		JLabel label_25 = new JLabel("10");
		label_25.setBounds(295, 96, 46, 14);
		panel_13.add(label_25);
		
		JPanel panel_3 = new JPanel();
		tabbedPane.addTab("Shipping", wait, panel_3, null);
		panel_3.setLayout(null);
		
		JPanel panel_17 = new JPanel();
		panel_17.setBorder(new TitledBorder(null, "Container Building", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_17.setBounds(10, 52, 801, 211);
		panel_3.add(panel_17);
		panel_17.setLayout(null);
		
		JLabel lblNewLabel_3 = new JLabel(" White Wine Available");
		lblNewLabel_3.setBounds(216, 19, 110, 14);
		panel_17.add(lblNewLabel_3);
		
		JLabel lblRedWineAvailable = new JLabel(" Red Wine Available");
		lblRedWineAvailable.setBounds(216, 44, 110, 14);
		panel_17.add(lblRedWineAvailable);
		
		JLabel lblNewLabel_4 = new JLabel("Container Max Capacity");
		lblNewLabel_4.setBounds(216, 69, 129, 14);
		panel_17.add(lblNewLabel_4);
		
		JLabel lblNewLabel_5 = new JLabel("Qty White Wine Ship.");
		lblNewLabel_5.setBounds(216, 94, 129, 14);
		panel_17.add(lblNewLabel_5);
		
		JLabel lblQtyRedWine = new JLabel("Qty Red Wine Ship.");
		lblQtyRedWine.setBounds(216, 119, 129, 14);
		panel_17.add(lblQtyRedWine);
		
		lblXx = new JLabel("XX");
		lblXx.setBounds(349, 19, 46, 14);
		panel_17.add(lblXx);
		
		label = new JLabel("XX");
		label.setBounds(349, 44, 46, 14);
		panel_17.add(label);
		
		JLabel label_2 = new JLabel("4");
		label_2.setBounds(349, 69, 46, 14);
		panel_17.add(label_2);
		
		JButton btnNewButton_3 = new JButton("Build Container");
		btnNewButton_3.setAction(action_11);
		btnNewButton_3.setBounds(305, 177, 116, 23);
		panel_17.add(btnNewButton_3);
		
		JPanel panel_18 = new JPanel();
		panel_18.setBorder(new TitledBorder(null, "Containers", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_18.setBounds(544, 11, 247, 161);
		panel_17.add(panel_18);
		panel_18.setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane_6 = new JScrollPane();
		panel_18.add(scrollPane_6, BorderLayout.CENTER);
		
		table_6 = new JTable();
		table_6.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Cont. ID", "Qty. White", "Qty. Red"
			}
		));
		scrollPane_6.setViewportView(table_6);
		
		 btnNewButton_4 = new JButton("Ship");
		btnNewButton_4.setAction(action_13);
		btnNewButton_4.setBounds(627, 177, 89, 23);
		panel_17.add(btnNewButton_4);
		
		JButton btnDeleteContainer = new JButton("Delete Container");
		btnDeleteContainer.setAction(action_12);
		btnDeleteContainer.setBounds(431, 177, 129, 23);
		panel_17.add(btnDeleteContainer);
		
		JLabel lblNewLabel_6 = new JLabel("Cost per Container : $ 30");
		lblNewLabel_6.setBounds(406, 19, 128, 14);
		panel_17.add(lblNewLabel_6);
		
		comboBox = new JComboBox();
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"Sel. Q.", "0", "1", "2", "3", "4"}));
		comboBox.setBounds(349, 91, 72, 20);
		panel_17.add(comboBox);
		
		comboBox_1 = new JComboBox();
		comboBox_1.setModel(new DefaultComboBoxModel(new String[] {"Sel. Q.", "0", "1", "2", "3", "4"}));
		comboBox_1.setBounds(349, 116, 72, 20);
		panel_17.add(comboBox_1);
		
		JLabel label_13 = new JLabel("Importer Order Red");
		label_13.setBounds(10, 26, 121, 14);
		panel_17.add(label_13);
		
		textField_7 = new JTextField();
		textField_7.setHorizontalAlignment(SwingConstants.CENTER);
		textField_7.setEditable(false);
		textField_7.setColumns(10);
		textField_7.setBounds(134, 23, 62, 20);
		panel_17.add(textField_7);
		
		JLabel label_14 = new JLabel("Importer Backlog Red");
		label_14.setBounds(10, 51, 121, 14);
		panel_17.add(label_14);
		
		textField_8 = new JTextField();
		textField_8.setHorizontalAlignment(SwingConstants.CENTER);
		textField_8.setEditable(false);
		textField_8.setColumns(10);
		textField_8.setBounds(134, 48, 62, 20);
		panel_17.add(textField_8);
		
		JLabel label_15 = new JLabel("Importer Order White");
		label_15.setBounds(10, 79, 121, 14);
		panel_17.add(label_15);
		
		textField_9 = new JTextField();
		textField_9.setHorizontalAlignment(SwingConstants.CENTER);
		textField_9.setEditable(false);
		textField_9.setColumns(10);
		textField_9.setBounds(134, 76, 62, 20);
		panel_17.add(textField_9);
		
		JLabel label_16 = new JLabel("Importer Backlog White");
		label_16.setBounds(10, 104, 132, 14);
		panel_17.add(label_16);
		
		textField_10 = new JTextField();
		textField_10.setHorizontalAlignment(SwingConstants.CENTER);
		textField_10.setEditable(false);
		textField_10.setColumns(10);
		textField_10.setBounds(134, 101, 62, 20);
		panel_17.add(textField_10);
		
		JLabel lblNewLabel_2 = new JLabel("Shipping Management Panel");
		lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblNewLabel_2.setBounds(10, 11, 268, 20);
		panel_3.add(lblNewLabel_2);
		
		JPanel panel_19 = new JPanel();
		panel_19.setBorder(new TitledBorder(null, "Shipping History", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_19.setBounds(10, 263, 801, 229);
		panel_3.add(panel_19);
		panel_19.setLayout(null);
		
		JScrollPane scrollPane_7 = new JScrollPane();
		scrollPane_7.setBounds(10, 30, 400, 188);
		panel_19.add(scrollPane_7);
		
		table_7 = new JTable();
		table_7.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Week Shipped", "Units", "Qty. White", "Qty. Red", "Week Arrival"
			}
		));
		scrollPane_7.setViewportView(table_7);
		
		JPanel panel_2 = new JPanel();
		tabbedPane.addTab("Inventory / Backlog", null, panel_2, null);
		panel_2.setLayout(null);
		
		JLabel lblInventoryManagementPanel = new JLabel("Inventory Management Panel");
		lblInventoryManagementPanel.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblInventoryManagementPanel.setBounds(10, 11, 284, 30);
		panel_2.add(lblInventoryManagementPanel);
		
		JPanel panel_20 = new JPanel();
		panel_20.setBorder(new TitledBorder(null, "Inventory Information", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_20.setBounds(10, 51, 801, 206);
		panel_2.add(panel_20);
		panel_20.setLayout(null);
		
		JLabel lblWhiteWineInventory = new JLabel("White Wine Inventory");
		lblWhiteWineInventory.setBounds(21, 26, 125, 14);
		panel_20.add(lblWhiteWineInventory);
		
		JLabel lblRedWineInventory = new JLabel("Red Wine Inventory");
		lblRedWineInventory.setBounds(21, 51, 125, 14);
		panel_20.add(lblRedWineInventory);
		
		JLabel lblInventoryCostPer = new JLabel("Inventory Cost per Week");
		lblInventoryCostPer.setBounds(21, 76, 125, 14);
		panel_20.add(lblInventoryCostPer);
		
		JLabel lblCurrentWeek = new JLabel("Current Week Inv Costs");
		lblCurrentWeek.setBounds(21, 101, 125, 14);
		panel_20.add(lblCurrentWeek);
		
		JLabel lblCumulativeInventoryCosts = new JLabel("Cumulative Inventory Costs");
		lblCumulativeInventoryCosts.setBounds(21, 126, 134, 14);
		panel_20.add(lblCumulativeInventoryCosts);
		
		JPanel panel_21 = new JPanel();
		panel_21.setBorder(new TitledBorder(null, "Historical Inv. Data", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_21.setBounds(295, 26, 457, 166);
		panel_20.add(panel_21);
		panel_21.setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane_8 = new JScrollPane();
		panel_21.add(scrollPane_8, BorderLayout.CENTER);
		
		table_8 = new JTable();
		table_8.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Week", "Red Inventory", "White Inventory"
			}
		));
		scrollPane_8.setViewportView(table_8);
		
		textField_11 = new JTextField();
		textField_11.setBounds(165, 20, 86, 20);
		panel_20.add(textField_11);
		textField_11.setColumns(10);
		
		textField_12 = new JTextField();
		textField_12.setColumns(10);
		textField_12.setBounds(165, 45, 86, 20);
		panel_20.add(textField_12);
		
		textField_13 = new JTextField();
		textField_13.setText("$ 4");
		textField_13.setColumns(10);
		textField_13.setBounds(165, 70, 86, 20);
		panel_20.add(textField_13);
		
		textField_14 = new JTextField();
		textField_14.setColumns(10);
		textField_14.setBounds(165, 95, 86, 20);
		panel_20.add(textField_14);
		
		textField_15 = new JTextField();
		textField_15.setColumns(10);
		textField_15.setBounds(165, 120, 86, 20);
		panel_20.add(textField_15);
		
		JPanel panel_22 = new JPanel();
		panel_22.setLayout(null);
		panel_22.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Backlog Information", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_22.setBounds(10, 279, 801, 206);
		panel_2.add(panel_22);
		
		JLabel lblWhiteWineBacklog = new JLabel("White Wine Backlog");
		lblWhiteWineBacklog.setBounds(21, 26, 125, 14);
		panel_22.add(lblWhiteWineBacklog);
		
		JLabel lblRedWineBacklog = new JLabel("Red Wine Backlog");
		lblRedWineBacklog.setBounds(21, 51, 125, 14);
		panel_22.add(lblRedWineBacklog);
		
		JLabel lblBacklogCostPer = new JLabel("Backlog Cost per Week");
		lblBacklogCostPer.setBounds(21, 76, 125, 14);
		panel_22.add(lblBacklogCostPer);
		
		JLabel lblCurrentBacklogInv = new JLabel("Current Backlog Inv Costs");
		lblCurrentBacklogInv.setBounds(21, 101, 125, 14);
		panel_22.add(lblCurrentBacklogInv);
		
		JLabel lblCumulativeBacklogCosts = new JLabel("Cumulative Backlog Costs");
		lblCumulativeBacklogCosts.setBounds(21, 126, 134, 14);
		panel_22.add(lblCumulativeBacklogCosts);
		
		JPanel panel_23 = new JPanel();
		panel_23.setBorder(new TitledBorder(null, "Historical Inv. Data", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_23.setBounds(295, 26, 457, 166);
		panel_22.add(panel_23);
		panel_23.setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane_9 = new JScrollPane();
		panel_23.add(scrollPane_9, BorderLayout.CENTER);
		
		table_9 = new JTable();
		table_9.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Week", "Red Backlog", "White Backlog"
			}
		));
		scrollPane_9.setViewportView(table_9);
		
		textField_16 = new JTextField();
		textField_16.setColumns(10);
		textField_16.setBounds(165, 120, 86, 20);
		panel_22.add(textField_16);
		
		textField_17 = new JTextField();
		textField_17.setColumns(10);
		textField_17.setBounds(165, 95, 86, 20);
		panel_22.add(textField_17);
		
		textField_18 = new JTextField();
		textField_18.setText("$ 6");
		textField_18.setColumns(10);
		textField_18.setBounds(165, 70, 86, 20);
		panel_22.add(textField_18);
		
		textField_19 = new JTextField();
		textField_19.setColumns(10);
		textField_19.setBounds(165, 45, 86, 20);
		panel_22.add(textField_19);
		
		textField_20 = new JTextField();
		textField_20.setColumns(10);
		textField_20.setBounds(165, 20, 86, 20);
		panel_22.add(textField_20);
		
		JPanel panel_4 = new JPanel();
		tabbedPane.addTab("Summary Satistics", null, panel_4, null);
		panel_4.setLayout(null);
		
		JPanel panel_24 = new JPanel();
		panel_24.setBorder(new TitledBorder(null, "Financial Statistics", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_24.setBounds(10, 11, 801, 528);
		panel_4.add(panel_24);
		panel_24.setLayout(null);
		
		JLabel label_19 = new JLabel("Inventory Cost per Week");
		label_19.setBounds(10, 98, 125, 14);
		panel_24.add(label_19);
		
		textField_23 = new JTextField();
		textField_23.setText("$ 4");
		textField_23.setColumns(10);
		textField_23.setBounds(154, 92, 86, 20);
		panel_24.add(textField_23);
		
		JLabel label_20 = new JLabel("Current Week Inv Costs");
		label_20.setBounds(10, 123, 125, 14);
		panel_24.add(label_20);
		
		textField_24 = new JTextField();
		textField_24.setColumns(10);
		textField_24.setBounds(154, 117, 86, 20);
		panel_24.add(textField_24);
		
		JLabel label_21 = new JLabel("Cumulative Inventory Costs");
		label_21.setBounds(10, 148, 134, 14);
		panel_24.add(label_21);
		
		textField_25 = new JTextField();
		textField_25.setColumns(10);
		textField_25.setBounds(154, 142, 86, 20);
		panel_24.add(textField_25);
		
		JLabel label_17 = new JLabel("Backlog Cost per Week");
		label_17.setBounds(10, 179, 125, 14);
		panel_24.add(label_17);
		
		textField_21 = new JTextField();
		textField_21.setText("$ 6");
		textField_21.setColumns(10);
		textField_21.setBounds(154, 173, 86, 20);
		panel_24.add(textField_21);
		
		JLabel label_18 = new JLabel("Current Backlog Inv Costs");
		label_18.setBounds(10, 204, 125, 14);
		panel_24.add(label_18);
		
		textField_22 = new JTextField();
		textField_22.setColumns(10);
		textField_22.setBounds(154, 198, 86, 20);
		panel_24.add(textField_22);
		
		JLabel label_22 = new JLabel("Cumulative Backlog Costs");
		label_22.setBounds(10, 229, 134, 14);
		panel_24.add(label_22);
		
		textField_26 = new JTextField();
		textField_26.setColumns(10);
		textField_26.setBounds(154, 223, 86, 20);
		panel_24.add(textField_26);
		
		JLabel lblShippingCostPer = new JLabel("Shipping Cost per Unit");
		lblShippingCostPer.setBounds(10, 260, 125, 14);
		panel_24.add(lblShippingCostPer);
		
		textField_27 = new JTextField();
		textField_27.setText("$ 30");
		textField_27.setColumns(10);
		textField_27.setBounds(154, 254, 86, 20);
		panel_24.add(textField_27);
		
		JLabel lblCurrentShppingCosts = new JLabel("Current Shpping Costs");
		lblCurrentShppingCosts.setBounds(10, 285, 125, 14);
		panel_24.add(lblCurrentShppingCosts);
		
		textField_28 = new JTextField();
		textField_28.setColumns(10);
		textField_28.setBounds(154, 279, 86, 20);
		panel_24.add(textField_28);
		
		JLabel lblCumulativeShippingCosts = new JLabel("Cumulative Shipping Costs");
		lblCumulativeShippingCosts.setBounds(10, 310, 134, 14);
		panel_24.add(lblCumulativeShippingCosts);
		
		textField_29 = new JTextField();
		textField_29.setColumns(10);
		textField_29.setBounds(154, 304, 86, 20);
		panel_24.add(textField_29);
		
		JPanel panel_26 = new JPanel();
		panel_26.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Historical Financial Data", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_26.setBounds(265, 11, 526, 506);
		panel_24.add(panel_26);
		panel_26.setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane_10 = new JScrollPane();
		panel_26.add(scrollPane_10, BorderLayout.CENTER);
		
		table_10 = new JTable();
		table_10.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
					"Week", "Wine Cost", "Inv. Cost", "Backlog Cost", "Ship. Costs", "Total Costs", "Total Sale", "Profit", "C. Profit/Loss"
			}
		));
		scrollPane_10.setViewportView(table_10);
		
		JLabel lblTotalCosts = new JLabel("Total Costs");
		lblTotalCosts.setBounds(10, 341, 125, 14);
		panel_24.add(lblTotalCosts);
		
		textField_30 = new JTextField();
		textField_30.setColumns(10);
		textField_30.setBounds(154, 335, 86, 20);
		panel_24.add(textField_30);
		
		JLabel lblCumulativeTotalCosts = new JLabel("Cumulative Total Costs");
		lblCumulativeTotalCosts.setBounds(10, 366, 134, 14);
		panel_24.add(lblCumulativeTotalCosts);
		
		textField_31 = new JTextField();
		textField_31.setColumns(10);
		textField_31.setBounds(154, 360, 86, 20);
		panel_24.add(textField_31);
		
		JLabel lblSalePricePer = new JLabel("Sale price per Unit");
		lblSalePricePer.setBounds(10, 397, 125, 14);
		panel_24.add(lblSalePricePer);
		
		textField_32 = new JTextField();
		textField_32.setText("$ 60");
		textField_32.setColumns(10);
		textField_32.setBounds(154, 391, 86, 20);
		panel_24.add(textField_32);
		
		JLabel lblCurrentTotalSales = new JLabel("Current Total Sales");
		lblCurrentTotalSales.setBounds(10, 422, 125, 14);
		panel_24.add(lblCurrentTotalSales);
		
		textField_33 = new JTextField();
		textField_33.setColumns(10);
		textField_33.setBounds(154, 416, 86, 20);
		panel_24.add(textField_33);
		
		JLabel lblCumulativeSales = new JLabel("Cumulative Sales");
		lblCumulativeSales.setBounds(10, 447, 134, 14);
		panel_24.add(lblCumulativeSales);
		
		textField_34 = new JTextField();
		textField_34.setColumns(10);
		textField_34.setBounds(154, 441, 86, 20);
		panel_24.add(textField_34);
		
		JLabel lblTotalProfitloss = new JLabel("Total Profit (Loss)");
		lblTotalProfitloss.setBounds(10, 478, 125, 14);
		panel_24.add(lblTotalProfitloss);
		
		textField_35 = new JTextField();
		textField_35.setColumns(10);
		textField_35.setBounds(154, 472, 86, 20);
		panel_24.add(textField_35);
		
		JLabel lblCumulativeProfitloss = new JLabel("Cumulative Profit (Loss)");
		lblCumulativeProfitloss.setBounds(10, 503, 134, 14);
		panel_24.add(lblCumulativeProfitloss);
		
		textField_36 = new JTextField();
		textField_36.setColumns(10);
		textField_36.setBounds(154, 497, 86, 20);
		panel_24.add(textField_36);
		
		JLabel lblWineCostPer = new JLabel("Wine Cost per Pallet");
		lblWineCostPer.setBounds(10, 23, 125, 14);
		panel_24.add(lblWineCostPer);
		
		textField_37 = new JTextField();
		textField_37.setText("$ 30");
		textField_37.setColumns(10);
		textField_37.setBounds(154, 17, 86, 20);
		panel_24.add(textField_37);
		
		JLabel lblCurrentWeekWine = new JLabel("Current Week Wine Costs");
		lblCurrentWeekWine.setBounds(10, 48, 125, 14);
		panel_24.add(lblCurrentWeekWine);
		
		textField_38 = new JTextField();
		textField_38.setColumns(10);
		textField_38.setBounds(154, 42, 86, 20);
		panel_24.add(textField_38);
		
		JLabel lblCumulativeWineCosts = new JLabel("Cumulative Wine Costs");
		lblCumulativeWineCosts.setBounds(10, 73, 134, 14);
		panel_24.add(lblCumulativeWineCosts);
		
		textField_39 = new JTextField();
		textField_39.setColumns(10);
		textField_39.setBounds(154, 67, 86, 20);
		panel_24.add(textField_39);
		
		JPanel panel_5 = new JPanel();
		springLayout.putConstraint(SpringLayout.NORTH, panel_5, 6, SpringLayout.SOUTH, tabbedPane);
		springLayout.putConstraint(SpringLayout.WEST, panel_5, 0, SpringLayout.WEST, menuBar);
		springLayout.putConstraint(SpringLayout.SOUTH, panel_5, 0, SpringLayout.SOUTH, frmWineGameWine.getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, panel_5, 0, SpringLayout.EAST, menuBar);
		
		JMenu mnNewMenu = new JMenu("DB Connection");
		menuBar.add(mnNewMenu);
		panel_5.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		frmWineGameWine.getContentPane().add(panel_5);
		panel_5.setLayout(null);
		
		lblStatus = new JLabel("Game: " + values.getNGame());
		lblStatus.setBounds(8, 8, 150, 14);
		panel_5.add(lblStatus);
		
		JLabel lblStatus0 = new JLabel("Status: ");
		lblStatus0.setBounds(160, 8, 50, 14);
		panel_5.add(lblStatus0);
		
		lblStatus2 = new JLabel();
		lblStatus2.setBounds(200, 8,200, 14);
		panel_5.add(lblStatus2);
		
		JLabel lblStatus1 = new JLabel("Importer: ");
		lblStatus1.setBounds(400, 8, 70, 14);
		panel_5.add(lblStatus1);
		
		lblStatus4 = new JLabel("Ordering");
		lblStatus4.setBounds(450, 8,50, 14);
		panel_5.add(lblStatus4);
		
		JLabel lblStatus11 = new JLabel("Distributor: ");
		lblStatus11.setBounds(520, 8, 70, 14);
		panel_5.add(lblStatus11);
		
		lblStatus5 = new JLabel("Ordering");
		lblStatus5.setBounds(580, 8,50, 14);
		panel_5.add(lblStatus5);
		
		JLabel lblStatus12 = new JLabel("Retailer: ");
		lblStatus12.setBounds(640, 8, 70, 14);
		panel_5.add(lblStatus12);
		
		lblStatus6 = new JLabel("Ordering");
		lblStatus6.setBounds(685, 8,50, 14);
		panel_5.add(lblStatus6);
		
		
		JLabel lblTheWineGame = new JLabel("The Wine Game - Winery Module");
		springLayout.putConstraint(SpringLayout.NORTH, tabbedPane, 6, SpringLayout.SOUTH, lblTheWineGame);
		springLayout.putConstraint(SpringLayout.NORTH, lblTheWineGame, 6, SpringLayout.SOUTH, menuBar);
		springLayout.putConstraint(SpringLayout.WEST, lblTheWineGame, 10, SpringLayout.WEST, frmWineGameWine.getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, lblTheWineGame, 244, SpringLayout.WEST, frmWineGameWine.getContentPane());
		lblTheWineGame.setFont(new Font("Tahoma", Font.PLAIN, 16));
		frmWineGameWine.getContentPane().add(lblTheWineGame);
		
		JLabel lblNewJgoodiesTitle = new JLabel("Current Week");
		springLayout.putConstraint(SpringLayout.NORTH, lblNewJgoodiesTitle, 6, SpringLayout.SOUTH, menuBar);
		lblNewJgoodiesTitle.setFont(new Font("Tahoma", Font.PLAIN, 16));
		frmWineGameWine.getContentPane().add(lblNewJgoodiesTitle);
		
		textField_4 = new JTextField();
		textField_4.setHorizontalAlignment(SwingConstants.CENTER);
		springLayout.putConstraint(SpringLayout.EAST, lblNewJgoodiesTitle, -8, SpringLayout.WEST, textField_4);
		springLayout.putConstraint(SpringLayout.WEST, textField_4, 737, SpringLayout.WEST, frmWineGameWine.getContentPane());
		springLayout.putConstraint(SpringLayout.EAST, textField_4, -10, SpringLayout.EAST, frmWineGameWine.getContentPane());
		springLayout.putConstraint(SpringLayout.NORTH, textField_4, 6, SpringLayout.SOUTH, menuBar);
		
		JMenu mnAbout = new JMenu("About");
		menuBar.add(mnAbout);
		
		JMenuItem mntmNewMenuItem = new JMenuItem("New menu item");
		mntmNewMenuItem.setAction(action_18);
		mnAbout.add(mntmNewMenuItem);
		textField_4.setEditable(false);
		frmWineGameWine.getContentPane().add(textField_4);
		textField_4.setColumns(10);
		
		tabbedPane.addChangeListener(new ChangeListener() {
		      public void stateChanged(ChangeEvent e) {
		        if (values.getIDGame()==0 && tabbedPane.getSelectedIndex()!=0) {
		        	JOptionPane.showMessageDialog( null,
						       "Please join a game!",
						       "Error", JOptionPane.ERROR_MESSAGE);
		        	tabbedPane.setSelectedIndex(0);
		        } else {
		        	if (tabbedPane.getTabCount()==6 && values.getIDGame()!=0) {
		        		tabbedPane.removeTabAt(0);
		        	}
		        }
		      }
		    });
		
	}
	
	private void upStart(){
		lblStatus.setForeground(Color.BLUE);
		lblStatus.setText("Playing game: " + values.getNGame());
    	int[] ord = new int[4];
    	int[] prod = new int[2];
    	double[] fin = new double[12];
    	double[] ing = new double[2];
		try {
			connect.pop_tablaOrd(table,0);
			connect.pop_tablaBot(table_1,0);
			connect.pop_tablaShip(table_5,0);
			connect.pop_tablaInvback(table_2,0);
			connect.pop_tablaLin(table_4,1);
			connect.pop_tablaLin(table_3,2);
			connect.pop_tablaShip(table_7,0);
			connect.pop_tablaInv(table_8,0);
			connect.pop_tablaBack(table_9,0);
			connect.pop_tablaFin(table_10,0);
			ord=connect.getOrders(1);
			textField_4.setText(""+ values.getWeek());
			textField_6.setText(""+ord[0]);
			textField_5.setText(""+ord[1]);
			textField.setText(""+ord[2]);
			textField_1.setText(""+ord[3]);
			prod=connect.getProd1();
			textField_2.setText(""+prod[0]);
			textField_3.setText(""+prod[1]);
			lblNewLabel.setText(""+ connect.getProd(1,1));
			label_1.setText(""+ connect.getProd(2,1));
			label_3.setText(""+ connect.getProd(3,1));
			label_6.setText(""+ connect.getProd(4,1)*10 + " %");
			lblNewLabel_1.setText(""+ connect.getPrevWine(1));
			label_12.setText(""+ connect.getPrevWine(2));
			label_10.setText(""+ connect.getProd(1,2));
			label_9.setText(""+ connect.getProd(2,2));
			label_8.setText(""+ connect.getProd(3,2));
			label_7.setText(""+ connect.getProd(4,2)*10 + " %");
			lblXx.setText(connect.getWineAvailW(1));
			label.setText(connect.getWineAvailW(2));
			textField_7.setText(""+ord[0]);
			textField_8.setText(""+ord[1]);
			textField_9.setText(""+ord[2]);
			textField_10.setText(""+ord[3]);
			fin = connect.getFinB(0,values.getWeek());
			ing = connect.getIngB(0, values.getWeek());
			NumberFormat currencyFormatter =  NumberFormat.getCurrencyInstance(Locale.US);		
			textField_38.setText("" + currencyFormatter.format(fin[0]*30));
			textField_39.setText("" + currencyFormatter.format(fin[1]*30));
			textField_24.setText("" + currencyFormatter.format(fin[2]*4));
			textField_25.setText("" + currencyFormatter.format(fin[3]*4));
			textField_22.setText("" + currencyFormatter.format(fin[4]*6));
			textField_26.setText("" + currencyFormatter.format(fin[5]*6));
			textField_28.setText("" + currencyFormatter.format(fin[6]*30));
			textField_29.setText("" + currencyFormatter.format(fin[7]*30));
			textField_30.setText("" + currencyFormatter.format((fin[0] + fin[6])*30+fin[2]*4+fin[4]*6));
			textField_31.setText("" + currencyFormatter.format((fin[1] + fin[7])*30+fin[3]*4+fin[5]*6));
			textField_33.setText("" + currencyFormatter.format(ing[0]*60));
			textField_34.setText("" + currencyFormatter.format(ing[1]*60));
			textField_35.setText("" + currencyFormatter.format(ing[0]*60 - ((fin[0] + fin[6])*30+fin[2]*4+fin[4]*6)));
			textField_36.setText("" + currencyFormatter.format(ing[1]*60-((fin[1] + fin[7])*30+fin[3]*4+fin[5]*6)));
			textField_11.setText(""+fin[8]);
			textField_12.setText(""+fin[9]);
			textField_20.setText(""+fin[10]);
			textField_19.setText(""+fin[11]);
			textField_14.setText("" + currencyFormatter.format(fin[2]*4));
			textField_15.setText("" + currencyFormatter.format(fin[3]*4));
			textField_17.setText("" + currencyFormatter.format(fin[4]*6));
			textField_16.setText("" + currencyFormatter.format(fin[5]*6));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	private void reset(){
		tabbedPane.setIconAt(1,wait);
		tabbedPane.setIconAt(2,wait);
		
		//Enable Buttons
		 btnNewProdOrder.setEnabled(true);
		 btnDeleteProdOrder.setEnabled(true);
		 btnNewButton_1.setEnabled(true);
		 btnMoveOrderDwn.setEnabled(true);
		 btnNewButton.setEnabled(true);
		 values.setL1(false);
		 
		 button.setEnabled(true);
		 button_1.setEnabled(true);
		 button_2.setEnabled(true);
		 button_3.setEnabled(true);
		 btnNewButton_2.setEnabled(true);
	     values.setL2(false);
		
		btnNewButton_4.setEnabled(true);
		values.setShip(false);
	     
		lblStatus.setForeground(Color.BLUE);
		lblStatus.setText("Playing game: " + values.getNGame());
    	int[] ord = new int[4];
    	int[] prod = new int[2];
    	double[] fin = new double[12];
    	double[] ing = new double[2];
		try {
			connect.pop_tablaOrd(table,0);
			connect.pop_tablaBot(table_1,0);
			connect.pop_tablaShip(table_5,0);
			connect.pop_tablaShip(table_7,0);
			connect.pop_tablaInvback(table_2,0);
			connect.pop_tablaLin(table_4,1);
			connect.pop_tablaLin(table_3,2);
			connect.pop_tablaInv(table_8,0);
			connect.pop_tablaBack(table_9,0);
			connect.pop_tablaFin(table_10,0);
			ord=connect.getOrders(1);
			textField_4.setText(""+ values.getWeek());
			textField_6.setText(""+ord[0]);
			textField_5.setText(""+ord[1]);
			textField.setText(""+ord[2]);
			textField_1.setText(""+ord[3]);
			prod=connect.getProd1();
			textField_2.setText(""+prod[0]);
			textField_3.setText(""+prod[1]);
			lblNewLabel.setText(""+ connect.getProd(1,1));
			label_1.setText(""+ connect.getProd(2,1));
			label_3.setText(""+ connect.getProd(3,1));
			label_6.setText(""+ connect.getProd(4,1)*10 + " %");
			lblNewLabel_1.setText(""+ connect.getPrevWine(1));
			label_12.setText(""+ connect.getPrevWine(2));
			label_10.setText(""+ connect.getProd(1,2));
			label_9.setText(""+ connect.getProd(2,2));
			label_8.setText(""+ connect.getProd(3,2));
			label_7.setText(""+ connect.getProd(4,2)*10 + " %");
			lblXx.setText(connect.getWineAvailW(1));
			label.setText(connect.getWineAvailW(2));
			textField_7.setText(""+ord[0]);
			textField_8.setText(""+ord[1]);
			textField_9.setText(""+ord[2]);
			textField_10.setText(""+ord[3]);
			fin = connect.getFinB(0,values.getWeek());
			ing = connect.getIngB(0, values.getWeek());
			NumberFormat currencyFormatter =  NumberFormat.getCurrencyInstance(Locale.US);	
			textField_38.setText("" + currencyFormatter.format(fin[0]*30));
			textField_39.setText("" + currencyFormatter.format(fin[1]*30));
			textField_24.setText("" + currencyFormatter.format(fin[2]*4));
			textField_25.setText("" + currencyFormatter.format(fin[3]*4));
			textField_22.setText("" + currencyFormatter.format(fin[4]*6));
			textField_26.setText("" + currencyFormatter.format(fin[5]*6));
			textField_28.setText("" + currencyFormatter.format(fin[6]*30));
			textField_29.setText("" + currencyFormatter.format(fin[7]*30));
			textField_30.setText("" + currencyFormatter.format((fin[0] + fin[6])*30+fin[2]*4+fin[4]*6));
			textField_31.setText("" + currencyFormatter.format((fin[1] + fin[7])*30+fin[3]*4+fin[5]*6));
			textField_33.setText("" + currencyFormatter.format(ing[0]*60));
			textField_34.setText("" + currencyFormatter.format(ing[1]*60));
			textField_35.setText("" + currencyFormatter.format(ing[0]*60 - ((fin[0] + fin[6])*30+fin[2]*4+fin[4]*6)));
			textField_36.setText("" + currencyFormatter.format(ing[1]*60-((fin[1] + fin[7])*30+fin[3]*4+fin[5]*6)));
			textField_11.setText(""+fin[8]);
			textField_12.setText(""+fin[9]);
			textField_20.setText(""+fin[10]);
			textField_19.setText(""+fin[11]);
			textField_14.setText("" + currencyFormatter.format(fin[2]*4));
			textField_15.setText("" + currencyFormatter.format(fin[3]*4));
			textField_17.setText("" + currencyFormatter.format(fin[4]*6));
			textField_16.setText("" + currencyFormatter.format(fin[5]*6));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	 
	//Variables Private
	 
	private JTabbedPane tabbedPane; 
	private JPanel panel_1;
	 private JTextField textField;
	 private JTextField textField_1;
	 private JTable table;
	 private JTable table_1;
	 private JTextField textField_2;
	 private JTextField textField_3;
	 private JTextField textField_4;
	 private JTable table_2;
	 private JTextField textField_5;
	 private JTextField textField_6;
	 private JTable table_3;
	 private JTable table_4;
	 private JTable table_5;
	 public Timer timer;
	 private JLabel lblStatus;
	 private JLabel lblStatus2;
	 private JLabel lblStatus4;
	 private JLabel lblStatus5;
	 private JLabel lblStatus6;
	 private JLabel lblNewLabel;
	 private JLabel lblNewLabel_1;
	 private JLabel label_12;
	 private JLabel label_1;
	 private JLabel label_3;
	 private JLabel label_6;
	 private JLabel label_10;
	 private JLabel label_9;
	 private JLabel label_8;
	 private JLabel label_7;
	 private JLabel lblXx;
	 private JLabel label;
	 private JComboBox comboBox;
	 private JComboBox comboBox_1;
	 private JButton btnNewProdOrder;
	 private JButton btnDeleteProdOrder;
	 private JButton btnNewButton_1;
	 private JButton btnMoveOrderDwn;
	 private JButton btnNewButton;
	 private JButton button;
	 private JButton button_1;
	 private JButton button_2;
	 private JButton button_3;
	 private JButton btnNewButton_2;
	 private JButton btnNewButton_4;
	 private ImageIcon wait;
	 private ImageIcon go;
	 
	 private JButton button_4;
	 private final Action action = new SwingAction();
	 private final Action action_1 = new SwingAction_1();
	 private final Action action_2 = new SwingAction_2();
	 private final Action action_3 = new SwingAction_3();
	 private final Action action_4 = new SwingAction_4();
	 private final Action action_5 = new SwingAction_5();
	 private final Action action_6 = new SwingAction_6();
	 private final Action action_7 = new SwingAction_7();
	 private final Action action_8 = new SwingAction_8();
	 private final Action action_9 = new SwingAction_9();
	 private final Action action_10 = new SwingAction_10();
	 private JTable table_6;
	 private JTable table_7;
	 private JTable table_8;
	 private JTable table_9;
	 private final Action action_11 = new SwingAction_11();
	 private final Action action_12 = new SwingAction_12();
	 private final Action action_13 = new SwingAction_13();
	 private final Action action_14 = new SwingAction_14();
	 private final Action action_15 = new SwingAction_15();
	 private JTextField textField_7;
	 private JTextField textField_8;
	 private JTextField textField_9;
	 private JTextField textField_10;
	 private final Action action_16 = new SwingAction_16();
	 private final Action action_17 = new SwingAction_17();
	 private final Action action_18 = new SwingAction_18();
	 private JTextField textField_11;
	 private JTextField textField_12;
	 private JTextField textField_13;
	 private JTextField textField_14;
	 private JTextField textField_15;
	 private JTextField textField_16;
	 private JTextField textField_17;
	 private JTextField textField_18;
	 private JTextField textField_19;
	 private JTextField textField_20;
	 private JTextField textField_23;
	 private JTextField textField_24;
	 private JTextField textField_25;
	 private JTextField textField_21;
	 private JTextField textField_22;
	 private JTextField textField_26;
	 private JTextField textField_27;
	 private JTextField textField_28;
	 private JTextField textField_29;
	 private JTable table_10;
	 private JTextField textField_30;
	 private JTextField textField_31;
	 private JTextField textField_32;
	 private JTextField textField_33;
	 private JTextField textField_34;
	 private JTextField textField_35;
	 private JTextField textField_36;
	 private JTextField textField_37;
	 private JTextField textField_38;
	 private JTextField textField_39;
	 
	 class RemindTask extends TimerTask {
 
		    public void run() {
		    	connect.upStatcon();
		  	//Execute the look in the DB for new data
		    	int[] stat = new int[6];
		    	stat=connect.getStatus();
		    	if (stat[4]==4 || stat[5]!=values.getWeek()) {		    		
		    		if (stat[5]!=values.getWeek()) {
		    			System.out.println("Change " + stat[5]);
		    			lblStatus2.setForeground(Color.GREEN);
			    		lblStatus2.setText("Changing week.");
			    		values.setWeek(stat[5]);
			    		reset();
		    		} else {
		    			System.out.println("Wait ");
		    			lblStatus2.setForeground(Color.BLUE);
			    		lblStatus2.setText("Waiting for change in week.");
		    		}
		    	} else if (values.getIDGame()==0){
		    		lblStatus2.setForeground(Color.red);
		    		lblStatus2.setText("Please join a game.");
		    	} else {
		    		
		    		lblStatus2.setForeground(Color.red);
		    		lblStatus2.setText("Waiting for participants.");
		    	}
		    	if (stat[1]==1) {
		    		lblStatus4.setForeground(Color.GREEN);
		    		lblStatus4.setText("OK.");
		    	} else {	    		
		    		lblStatus4.setForeground(Color.red);
		    		lblStatus4.setText("Ordering.");
		    	}
		    	if (stat[2]==1) {
		    		lblStatus5.setForeground(Color.GREEN);
		    		lblStatus5.setText("OK.");
		    	} else {	    		
		    		lblStatus5.setForeground(Color.red);
		    		lblStatus5.setText("Ordering.");
		    	}
		    	if (stat[3]==1) {
		    		lblStatus6.setForeground(Color.GREEN);
		    		lblStatus6.setText("OK.");
		    	} else {	    		
		    		lblStatus6.setForeground(Color.red);
		    		lblStatus6.setText("Ordering.");
		    	}
		    }
		    
		  }
	private class SwingAction extends AbstractAction {
		public SwingAction() {
			putValue(NAME, "Join Game");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
				sel_game sel = new sel_game();
				sel.setVisible(true);
				sel.addWindowListener(new WindowListener() {
					@Override
					public void windowActivated(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowClosed(WindowEvent arg0) {
						// TODO Auto-generated method stub
						upStart();
						button_4.setEnabled(false);
					}
					@Override
					public void windowClosing(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowDeactivated(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowDeiconified(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowIconified(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowOpened(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
		        });
		}
	}
	private class SwingAction_1 extends AbstractAction {
		public SwingAction_1() {
			putValue(NAME, "Make bottling Order");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			tabbedPane.setSelectedIndex(1);
		}
	}
	private class SwingAction_2 extends AbstractAction {
		public SwingAction_2() {
			putValue(NAME, "Make Shippment");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			tabbedPane.setSelectedIndex(2);
		}
	}
	private class SwingAction_3 extends AbstractAction {
		public SwingAction_3() {
			putValue(NAME, "New Prod. Order");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
				bott_order sel = new bott_order(1);
				sel.setVisible(true);
				sel.addWindowListener(new WindowListener() {
					@Override
					public void windowActivated(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowClosed(WindowEvent arg0) {
						// TODO Auto-generated method stub
						upStart();
						button_4.setEnabled(false);
					}
					@Override
					public void windowClosing(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowDeactivated(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowDeiconified(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowIconified(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
					@Override
					public void windowOpened(WindowEvent arg0) {
						// TODO Auto-generated method stub
						
					}
		        });
		}
	}
	private class SwingAction_4 extends AbstractAction {
		public SwingAction_4() {
			putValue(NAME, "New Prod. Order");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			bott_order sel = new bott_order(2);
			sel.setVisible(true);
			sel.addWindowListener(new WindowListener() {
				@Override
				public void windowActivated(WindowEvent arg0) {
					// TODO Auto-generated method stub
					
				}
				@Override
				public void windowClosed(WindowEvent arg0) {
					// TODO Auto-generated method stub
					upStart();
					button_4.setEnabled(false);
				}
				@Override
				public void windowClosing(WindowEvent arg0) {
					// TODO Auto-generated method stub
					
				}
				@Override
				public void windowDeactivated(WindowEvent arg0) {
					// TODO Auto-generated method stub
					
				}
				@Override
				public void windowDeiconified(WindowEvent arg0) {
					// TODO Auto-generated method stub
					
				}
				@Override
				public void windowIconified(WindowEvent arg0) {
					// TODO Auto-generated method stub
					
				}
				@Override
				public void windowOpened(WindowEvent arg0) {
					// TODO Auto-generated method stub
					
				}
	        });
		}
	}
	private class SwingAction_5 extends AbstractAction {
		public SwingAction_5() {
			putValue(NAME, "Delete Prod. Order");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			if (table_4.getSelectedRow()!=-1) {
				int n = JOptionPane.showConfirmDialog(
					    null,
					    "Delete Order!",
					    "Delete Plan",
					    JOptionPane.YES_NO_OPTION);
				if(n==0) {
					Connection conn =  connect.connect_DB();
					 try {
						
				    int ID = (int) table_4.getModel().getValueAt(table_4.getSelectedRow(),0);
				    String query = "DELETE FROM bottling WHERE ID=?"; 
				    PreparedStatement ps = conn.prepareStatement(query);
					ps.setInt(1, ID);
					ps.execute();
					connect.check_setup(1);
					 } catch (SQLException i) {
							// TODO Auto-generated catch block
							i.printStackTrace();
						}
					 upStart();
				}
		}
	}
	}
	private class SwingAction_6 extends AbstractAction {
		public SwingAction_6() {
			putValue(NAME, "Move Order Up");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			if (table_4.getSelectedRow()!=-1) {
				int[] ID = new int[2];
				int[] Seq = new int[2];
				ID[0] = (int) table_4.getModel().getValueAt(table_4.getSelectedRow(),0);
				ID[1] = (int) table_4.getModel().getValueAt(table_4.getSelectedRow()-1,0);
				try {
					 Connection conn =  connect.connect_DB();
				for (int i=0;i<2;i++) {
					  String query = "SELECT Seq FROM Bottling Where ID=?";
			  		  PreparedStatement ps=conn.prepareStatement(query);
			  		  ps.setInt(1, ID[i]);
			  		  ResultSet rs = ps.executeQuery();
			  		  while ( rs.next() ) {
			  			  Seq[i]=rs.getInt(1);
			  		  }
					}
				for (int i=0;i<2;i++) {
				      String query = "UPDATE Bottling SET Seq=? Where ID=?";
				      PreparedStatement ps=conn.prepareStatement(query);
				      if (i==0) {
				    	  ps.setInt(1, Seq[1]);
				      } else {
				    	  ps.setInt(1, Seq[0]);
				      }
			  		  ps.setInt(2, ID[i]);
			  		  ps.execute();
				}
				connect.check_setup(1);
					} catch (SQLException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
				 upStart();
			}
		}
	}
	private class SwingAction_7 extends AbstractAction {
		public SwingAction_7() {
			putValue(NAME, "Move Order Down");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			if (table_4.getSelectedRow()!=-1) {
				int[] ID = new int[2];
				int[] Seq = new int[2];
				ID[0] = (int) table_4.getModel().getValueAt(table_4.getSelectedRow(),0);
				ID[1] = (int) table_4.getModel().getValueAt(table_4.getSelectedRow()+1,0);
				try {
					 Connection conn =  connect.connect_DB();
				for (int i=0;i<2;i++) {
					  String query = "SELECT Seq FROM Bottling Where ID=?";
			  		  PreparedStatement ps=conn.prepareStatement(query);
			  		  ps.setInt(1, ID[i]);
			  		  ResultSet rs = ps.executeQuery();
			  		  while ( rs.next() ) {
			  			  Seq[i]=rs.getInt(1);
			  		  }
					}
				for (int i=0;i<2;i++) {
				      String query = "UPDATE Bottling SET Seq=? Where ID=?";
				      PreparedStatement ps=conn.prepareStatement(query);
				      if (i==0) {
				    	  ps.setInt(1, Seq[1]);
				      } else {
				    	  ps.setInt(1, Seq[0]);
				      }
			  		  ps.setInt(2, ID[i]);
			  		  ps.execute();
				}
				connect.check_setup(1);
					} catch (SQLException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
				 upStart();
			}
		}
	}
	private class SwingAction_8 extends AbstractAction {
		public SwingAction_8() {
			putValue(NAME, "Delete Prod. Order");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			if (table_3.getSelectedRow()!=-1) {
				int n = JOptionPane.showConfirmDialog(
					    null,
					    "Delete Order!",
					    "Delete Plan",
					    JOptionPane.YES_NO_OPTION);
				if(n==0) {
					Connection conn =  connect.connect_DB();
					 try {
						
				    int ID = (int) table_3.getModel().getValueAt(table_3.getSelectedRow(),0);
				    String query = "DELETE FROM bottling WHERE ID=?"; 
				    PreparedStatement ps = conn.prepareStatement(query);
					ps.setInt(1, ID);
					ps.execute();
					connect.check_setup(2);
					 } catch (SQLException i) {
							// TODO Auto-generated catch block
							i.printStackTrace();
						}
					 upStart();
				}
		}
		}
	}
	private class SwingAction_9 extends AbstractAction {
		public SwingAction_9() {
			putValue(NAME, "Move Order Up");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			if (table_3.getSelectedRow()!=-1) {
				int[] ID = new int[2];
				int[] Seq = new int[2];
				ID[0] = (int) table_3.getModel().getValueAt(table_3.getSelectedRow(),0);
				ID[1] = (int) table_3.getModel().getValueAt(table_3.getSelectedRow()-1,0);
				try {
					 Connection conn =  connect.connect_DB();
				for (int i=0;i<2;i++) {
					  String query = "SELECT Seq FROM Bottling Where ID=?";
			  		  PreparedStatement ps=conn.prepareStatement(query);
			  		  ps.setInt(1, ID[i]);
			  		  ResultSet rs = ps.executeQuery();
			  		  while ( rs.next() ) {
			  			  Seq[i]=rs.getInt(1);
			  		  }
					}
				for (int i=0;i<2;i++) {
				      String query = "UPDATE Bottling SET Seq=? Where ID=?";
				      PreparedStatement ps=conn.prepareStatement(query);
				      if (i==0) {
				    	  ps.setInt(1, Seq[1]);
				      } else {
				    	  ps.setInt(1, Seq[0]);
				      }
			  		  ps.setInt(2, ID[i]);
			  		  ps.execute();
				}
				connect.check_setup(2);
					} catch (SQLException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
				 upStart();
			}
			
		}
	}
	private class SwingAction_10 extends AbstractAction {
		public SwingAction_10() {
			putValue(NAME, "Move Order Down");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			if (table_3.getSelectedRow()!=-1) {
				int[] ID = new int[2];
				int[] Seq = new int[2];
				ID[0] = (int) table_3.getModel().getValueAt(table_3.getSelectedRow(),0);
				ID[1] = (int) table_3.getModel().getValueAt(table_3.getSelectedRow()+1,0);
				try {
					 Connection conn =  connect.connect_DB();
				for (int i=0;i<2;i++) {
					  String query = "SELECT Seq FROM Bottling Where ID=?";
			  		  PreparedStatement ps=conn.prepareStatement(query);
			  		  ps.setInt(1, ID[i]);
			  		  ResultSet rs = ps.executeQuery();
			  		  while ( rs.next() ) {
			  			  Seq[i]=rs.getInt(1);
			  		  }
					}
				for (int i=0;i<2;i++) {
				      String query = "UPDATE Bottling SET Seq=? Where ID=?";
				      PreparedStatement ps=conn.prepareStatement(query);
				      if (i==0) {
				    	  ps.setInt(1, Seq[1]);
				      } else {
				    	  ps.setInt(1, Seq[0]);
				      }
			  		  ps.setInt(2, ID[i]);
			  		  ps.execute();
			  		  conn.close();
				}
				connect.check_setup(2);
					} catch (SQLException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
				 upStart();
			}
		}
	}
	private class SwingAction_11 extends AbstractAction {
		public SwingAction_11() {
			putValue(NAME, "Build Container");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			if (comboBox.getSelectedIndex()!=0) {
				if (comboBox_1.getSelectedIndex()!=0) {	
					int White = Integer.parseInt(comboBox.getSelectedItem().toString()); 
					int Red = Integer.parseInt(comboBox_1.getSelectedItem().toString()); 
				if (connect.ckWineAvail(table_6, Integer.parseInt(lblXx.getText()), 1, White) && connect.ckWineAvail(table_6, Integer.parseInt(label.getText()), 2, Red) ) {	
				if ((White+Red)<=4) {	
					Object[] result = new Object[3];
					result[0] = table_6.getRowCount();
					result[1] = comboBox.getSelectedItem();
					result[2]= comboBox_1.getSelectedItem();
					
					((DefaultTableModel)table_6.getModel()).addRow(result);
					comboBox.setSelectedIndex(0);
					comboBox_1.setSelectedIndex(0);
				} else {	JOptionPane.showMessageDialog( null,
					       "The total amount exeeds capacity of container!",
					       "Error", JOptionPane.ERROR_MESSAGE);
			    }	
				} else {	JOptionPane.showMessageDialog( null,
					       "The total amount shipped exeeds availability!",
					       "Error", JOptionPane.ERROR_MESSAGE);
			    }		
				} else {	JOptionPane.showMessageDialog( null,
					       "Select amount Red wine to Ship!",
					       "Error", JOptionPane.ERROR_MESSAGE);
			}	
			} else {	JOptionPane.showMessageDialog( null,
					       "Select amount White wine to Ship!",
					       "Error", JOptionPane.ERROR_MESSAGE);
			}
			
			
		}
	}
	private class SwingAction_12 extends AbstractAction {
		public SwingAction_12() {
			putValue(NAME, "Delete Container");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			if (table_6.getSelectedRow()!=-1) {
				((DefaultTableModel)table_6.getModel()).removeRow(table_6.getSelectedRow());
			} else {	JOptionPane.showMessageDialog( null,
				       "Select a container to delete!",
				       "Error", JOptionPane.ERROR_MESSAGE);
		}
		}
	}
	private class SwingAction_13 extends AbstractAction {
		public SwingAction_13() {
			putValue(NAME, "Ship");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			//Make Shipment
			int filas = ((DefaultTableModel)table_6.getModel()).getRowCount();
			int swhite =0;
			int sred =0;
			int uni = 0;
			int awhite = Integer.parseInt(lblXx.getText().toString());
			int ared = Integer.parseInt(label.getText().toString());
			for (int i=0;i<filas;i++) {
				swhite= swhite + Integer.parseInt(table_6.getModel().getValueAt(i, 1).toString());
				sred= sred + Integer.parseInt(table_6.getModel().getValueAt(i, 2).toString());
			}
			if ((awhite>=swhite) && (ared>=sred)) {
			try {
				 Connection conn =  connect.connect_DB();
				 String query = "INSERT INTO shipping (Game_ID, Level, Semana, units, Ship_red, Ship_White) VALUES (?,?,?,?,?,?)";
				 PreparedStatement ps=conn.prepareStatement(query);
		  		  ps.setInt(1, values.getIDGame());
		  		  ps.setInt(2,0);
		  		  ps.setInt(3, values.getWeek()+1);
		  		  ps.setInt(4, filas);
		  		  ps.setInt(5, sred);
		  		  ps.setInt(6, swhite);
		  		ps.execute();
		  		ps.close();
		  		conn.close();
		  		
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			btnNewButton_4.setEnabled(false);
			tabbedPane.setIconAt(2,go);
			values.setShip(true);
			  if (values.getL1() && values.getShip() && values.getL2()) {
			  connect.fin();
			  }
			} else {
				JOptionPane.showMessageDialog( null,
					       "You do not have enough red or White wine to ship!",
					       "Error", JOptionPane.ERROR_MESSAGE);
			}
		}
	}
	
	protected static ImageIcon createImageIcon(String path) {
        File imgURL = new File(path);
        if (imgURL != null) {
            return new ImageIcon(path);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }
	private class SwingAction_14 extends AbstractAction {
		public SwingAction_14() {
			putValue(NAME, "Execute Bottling Plan");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			int n = JOptionPane.showConfirmDialog(
				    null,
				    "Submit bottling plan for Line 1?",
				    "Submit",
				    JOptionPane.YES_NO_OPTION);
			if(n==0) {
				
				
			 btnNewProdOrder.setEnabled(false);
			 btnDeleteProdOrder.setEnabled(false);
			 btnNewButton_1.setEnabled(false);
			 btnMoveOrderDwn.setEnabled(false);
			 btnNewButton.setEnabled(false);
			 values.setL1(true);
			 if (values.getL1() && values.getL2()) {
			 connect.setBot();
			 tabbedPane.setIconAt(1,go);
			 }
		}
		}
	}
	private class SwingAction_15 extends AbstractAction {
		public SwingAction_15() {
			putValue(NAME, "Excecute Bottling Plan");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {

			int n = JOptionPane.showConfirmDialog(
				    null,
				    "Submit bottling plan for Line 2?",
				    "Submit",
				    JOptionPane.YES_NO_OPTION);
			if(n==0) {
				 button.setEnabled(false);
				 button_1.setEnabled(false);
				 button_2.setEnabled(false);
				 button_3.setEnabled(false);
				 btnNewButton_2.setEnabled(false);
			     values.setL2(true);
				 if (values.getL1() && values.getL2()) {
					 connect.setBot();
					 tabbedPane.setIconAt(1,go);
					 }
		}
		
		}
	}
	private class SwingAction_16 extends AbstractAction {
		public SwingAction_16() {
			putValue(NAME, "Make a Shipment");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			tabbedPane.setSelectedIndex(1);
		}
	}
	private class SwingAction_17 extends AbstractAction {
		public SwingAction_17() {
			putValue(NAME, "Make a Bottling Order");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			tabbedPane.setSelectedIndex(2);
		}
	}
	private class SwingAction_18 extends AbstractAction {
		public SwingAction_18() {
			putValue(NAME, "About Wine Game");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
			splash spl = new splash();
		}
	}
	}


